<template>
  <div class="community">
    <!-- 头部 -->
    <div class="community-fixed-top">
      <div class="fixed-top-left">
        <p class="icon"></p>
        <p class="text">Roader 社区</p>
      </div>
      <div @click="show = !show" class="fixed-top-right">
        <p class="text">{{classifyName}}</p>
        <img src="../../../assets/images/community/001.png" class="icon"/>
      </div>
    </div>
    <transition name="fade">
      <div class="fixed-top-wrap">
        <div class="fixed-top-item" v-if="show">
          <div class="fixed-top-list" v-for="(item,index) in classifyArr" @click="chooseClassifyList(item.modname)">
            {{item.modname}}
          </div>
        </div>
      </div>
    </transition>
    <!-- 主题 -->
    <div class="community-content">
      <div class="community-all">
        <div class="left">
          <div class="item" v-for="(item,index) in list" @click="onDetailTap">
            <img class="item-img" :src="item.pic"/>
            <p class="item-title">{{item.bbstitle}}</p>
            <div class="item-info">
              <div class="info-left">
                <img class="info-avatar" :src="item.headimgurl"></img>
                <p class="info-name">{{item.nickname}}</p>
              </div>
              <div class="info-right">
                <img class="info-like" src="../../../assets/images/community/004.png"/>
                <p class="info-num">{{item.prizenum}}</p>
              </div>
            </div>
            <!-- 地址 -->
            <div class="item-address" v-if="item.address">
              <img src="../../../assets/images/community/007.png" class="address-icon"/>
              <p class="address-text">{{item.address}}</p>
            </div>
          </div>
        </div>
        <div class="right">
          <div class="item" v-for="(item,index) in list" @click="onDetailTap">
            <img class="item-img" :src="item.pic"/>
            <p class="item-title">{{item.bbstitle}}</p>
            <div class="item-info">
              <div class="info-left">
                <img class="info-avatar" :src="item.headimgurl"></img>
                <p class="info-name">{{item.nickname}}</p>
              </div>
              <div class="info-right">
                <img class="info-like" src="../../../assets/images/community/004.png"/>
                <p class="info-num">{{item.prizenum}}</p>
              </div>
            </div>
            <!-- 地址 -->
            <div class="item-address" v-if="item.address">
              <img src="../../../assets/images/community/007.png" class="address-icon"/>
              <p class="address-text">{{item.address}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- flex -->
    <div class="community-btn" @click='onReleaseTap'>
      <img src="../../../assets/images/community/008.png"/>
    </div>
  </div>
</template>

<script>
  export default {
    name: "community",
    data() {
      return {
        classifyArr: [{'modname': '健身'}, {'modname': '减肥'}, {'modname': '全部'}],
        list: [{
          'bbstitle': '健身',
          'nickname': '游戏性',
          'prizenum': '2',
          'address': '湖北省武汉市洪山区追涨杀跌我的一组',
          "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
          "headimgurl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
        },
          {

            'bbstitle': '健身',
            'nickname': '游戏性',
            'prizenum': '2',
            "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
            "headimgurl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
          },
          {

            'bbstitle': '健身',
            'nickname': '游戏性',
            'prizenum': '2',
            'address': '湖北省武汉市洪山区追涨杀跌我的一组',
            "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
            "headimgurl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
          },
          {

            'bbstitle': '健身',
            'nickname': '游戏性',
            'prizenum': '2',
            'address': '湖北省武汉市洪山区追涨杀跌我的一组',
            "pic": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
            "headimgurl": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1519986512144&di=1ca08b2fe057e5d8089378ade12d834c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fb21bb051f8198618b4505a5040ed2e738ad4e6cb.jpg",
          }
        ],
        allArr: [],
        fadeFlag: true,
        isLogin: false,
        classifyName: '全部',
        show: false,
      }
    },
    methods: {
      chooseClassifyList(modname) {
        this.classifyName = modname
        this.show = false
      },
      onReleaseTap() {
        this.$router.push('/communityWrite');
      },
      onDetailTap() {
        this.$router.push('/communityDetail');
      }
    }
  }
</script>

<style scoped lang="less">
  .fade-enter-active, .fade-leave-active {
    transition: opacity .5s;
  }

  .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
    opacity: 0;
  }

  .community {
    background: #f5f5fa;
    .community-fixed-top {
      width: 100%;
      height: 40px;
      display: flex;
      padding: 0 6px;
      box-sizing: border-box;
      background: #1bbacd;
      position: fixed;
      top: 0;
      left: 0;
      align-items: center;
      justify-content: space-between;
      .fixed-top-left {
        font-size: 0;
        .icon {
          width: 3px;
          height: 18px;
          background: #35cfe1;
          display: inline-block;
          vertical-align: middle;
        }
      }
      .fixed-top-right {
        font-size: 0;
        .icon {
          width: 16px;
          height: 7px;
          display: inline-block;
          vertical-align: middle;
          margin-left: 8px;
        }
      }
      .fixed-top-left .text, .fixed-top-right .text {
        font-size: 18px;
        color: #fff;
        margin-left: 8px;
        display: inline-block;
        vertical-align: middle;
      }

    }
    .fixed-top-wrap {
      position: fixed;
      right: 7px;
      top: 40px;
      width: 65px;
      background: #fff;
      z-index: 9;
      text-align: center;
      /*opacity: 0;*/
      box-shadow: 0 4px 12px 0 rgba(7, 17, 27, .1);
      .fixed-top-item {
        width: 100%;
        padding: 0 5px;
        box-sizing: border-box;
        .fixed-top-list {
          height: 30px;
          line-height: 30px;
          border-bottom: 1px solid #dddcdc;
          box-sizing: border-box;
          font-size: 14px;
          color: #666;
        }

        .fixed-top-list:last-child {
          border-bottom: none;
        }

      }
    }
    .community-btn {
      position: fixed;
      width: 40px;
      height: 40px;
      right: 4%;
      bottom: 20%;
      padding: 0;
      border-radius: 50%;
      background: none;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }

  .community-content {
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    .community-all {
      margin: 40px 0 70px 0;
      .left, .right {
        display: inline-block;
        width: 49%;
        .item {
          text-align: left;
          width: 100%;
          background: #fff;
          margin-top: 10px;
          display: inline-block;
          padding-bottom: 12px;
          box-shadow: 0 4px 12px 0 rgba(7, 17, 27, .1);
          .item-img {
            width: 100%;
            height: 200px;
          }
          .item-title {
            font-size: 14px;
            color: #131313;
            width: 100%;
            padding: 0 10px;
            box-sizing: border-box;
          }
          .item-info {
            font-size: 10px;
            width: 100%;
            padding: 0 10px;
            box-sizing: border-box;
            margin-top: 5px;
            display: flex;
            justify-content: space-between;
            .info-left {
              flex: 1;
              .info-avatar {
                width: 18px;
                height: 18px;
                display: inline-block;
                vertical-align: middle;
                border-radius: 50%;
              }
              .info-name {
                color: #666;
                margin-left: 2px;
                display: inline-block;
                vertical-align: middle;
              }

            }
            .info-right {
              width: 50px;
              flex: 0 0 50px;
              justify-content: flex-end;
              display: flex;
              align-items: center;
              .info-like {
                width: 14px;
                height: 12px;
                margin-right: 4px;
              }
              .info-num {
                color: #666;
                display: inline-block;
                vertical-align: middle;
              }
            }
          }
          .item-address {
            width: 100%;
            padding: 0 10px;
            box-sizing: border-box;
            display: flex;
            margin-top: 7px;
            align-items: center;
            .address-icon {
              width: 8px;
              height: 12px;
              flex: 0 0 8px;
            }
            .address-text {
              font-size: 8px;
              color: #b9b9b9;
              margin-left: 5px;
            }
          }
        }
      }
    }

  }


</style>
